package com.zpself.module.算法练习.算法;

/**
 * @author By ZengPeng
 * @Description 给定一个整数，编写一个函数来判断它是否是 2 的幂次方。
 * @date in  2021/1/20 19:13
 * @Modified By
 */
public class 力扣_231_2的幂 {
    public static void main(String[] args) {
        System.out.println(0%2);
        System.out.println(myAnswer(0));
        System.out.println(myAnswer(1));
        System.out.println(myAnswer(4));
        System.out.println(myAnswer(6));
        System.out.println(myAnswer(8));
    }

    public static boolean myAnswer(int n){
        if(n==0) return false;
        while (n!=1){
            if(n%2!=0)
                return false;
            n = n/2;
        }
        return true;
    }
}
